<?php
declare (strict_types=1);
namespace App\Model;

use Hyperf\DbConnection\Model\Model;

class BaseModel extends Model
{
    protected static $_p_size = 15;

    public static function p_offset($page, $size)
    {
        $page = intval($page);
        if ($page <= 0)
        {
            $page = 1;
        }

        $size = self::p_size($size);

        return ($page - 1) * $size;
    }

    public static function p_size($size)
    {
        if (intval($size) <= 0)
        {
            $size = self::$_p_size;
        }
        return (int)$size;
    }
}